package cn.minhx.domain.activity.service.discount.impl;

import cn.minhx.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.minhx.domain.activity.service.discount.AbstractDiscountCalculator;
import com.alibaba.fastjson2.JSON;
import java.math.BigDecimal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 折扣
 *
 * @author min
 */
@Slf4j
@Service("ZK")
public class ZKCalculator extends AbstractDiscountCalculator {

	@Override
	protected BigDecimal doCalculate(BigDecimal originalPrice,
			GroupBuyActivityDiscountVO.GroupBuyDiscount groupBuyDiscount) {
		log.info("优惠策略-折扣计算 originalPrice:{} groupBuyDiscount:{}", originalPrice, JSON.toJSONString(groupBuyDiscount));
		// 折扣表达式 - 折扣百分比
		String marketExpr = groupBuyDiscount.getMarketExpr();
		// 折后价格
		return originalPrice.multiply(new BigDecimal(marketExpr));
	}
}
